package com.ayoka.parenting.ui.coach.studentdetail;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.CoachInviteCodeBean;
import com.ayoka.parenting.bean.GrownPathBean;
import com.ayoka.parenting.bean.PagerBean;
import com.ayoka.parenting.bean.StudentBean;
import com.ayoka.parenting.bean.UserInfoBean;
import com.ayoka.parenting.bean.UserInfoDetailBean;
import com.ayoka.parenting.interf.SimpleRequestCallback;
import com.ayoka.parenting.mvp.BasePresenterImpl;
import com.jincp.common.utils.UIUtils;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: StudentDetailPresenter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class StudentDetailPresenter extends BasePresenterImpl<StudentDetailContract.View> implements StudentDetailContract.Presenter{

    private StudentDetailModel model;

     public StudentDetailPresenter() {
        model = new StudentDetailModel();
     }

    @Override
    public void getStudentData(String studentId) {
        model.getStudentData(this, studentId, new SimpleRequestCallback<UserInfoDetailBean>() {
            @Override
            public void onSuccess(UserInfoDetailBean data) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().configStudentData(data);
            }

            @Override
            public void onFailure(int errCode, String errMsg) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().showToast(errMsg);
            }
        });
    }

    @Override
    public void getStudentGrowPathListData(boolean isShowWaitDialog, String studentId, int pageNo, int pageSize) {
        if (isShowWaitDialog) {
            mView.get().showWaitDialog(UIUtils.getString(R.string.loading));
        }
        model.getStudentGrowPathListData(this, studentId, pageNo, pageSize, new SimpleRequestCallback<PagerBean<GrownPathBean>>() {
            @Override
            public void onSuccess(PagerBean<GrownPathBean> data) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().configStudentGrowPathListData(data);
            }

            @Override
            public void onFailure(int errCode, String errMsg) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().showToast(errMsg);
            }
        });
    }
}
